package com.tgg.treeproject.utils;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.mail.MailAccount;
import cn.hutool.extra.mail.MailUtil;

import java.io.File;
import java.util.ArrayList;

public class EmailUtils {
    public EmailUtils() {

    }

    /**
     * 信息摘要
     * @param emailList 收件人列表
     * @param subject 主题
     * @param content 邮件内容(支持HTML)
     * @return
     */

    public  Boolean SendEmail(ArrayList<String> emailList, String subject, String content) {
        MailAccount account = new MailAccount();
        account.setHost("smtp.163.com");
        account.setPort(25);
        account.setAuth(true);
        account.setFrom("kmulove@163.com");
        account.setUser("kmulove");
        account.setPass("VCCHTGEZDTEJHUVD");

        try {
            String send = MailUtil.send(account, CollUtil.newArrayList(emailList), subject, content, true);
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    /**
     * 信息摘要
     * @param emailList 收件人列表
     * @param subject 主题
     * @param content 邮件内容(支持HTML)
     * @param file 附件
     * @return
     */

    public   Boolean SendFileEmail(ArrayList<String> emailList, String subject, String content, File file) {
        MailAccount account = new MailAccount();
        account.setHost("smtp.163.com");
        account.setPort(25);
        account.setAuth(true);
        account.setFrom("kmulove@163.com");
        account.setUser("kmulove");
        account.setPass("VCCHTGEZDTEJHUVD");
        try {
            String send = MailUtil.send(account, CollUtil.newArrayList(emailList), subject, content, true, file);
        } catch (Exception e) {
            return false;
        }
        return true;
    }


}
